#pragma once

class IconButton : public UIElement
{
	static Texture* mHoverTexture;
	Texture* mIconTexture;
	Vertex3FRHWT mVertices[4];
	ui32 mSize;
	ui32 mPosX, mPosY;
	bool mIsHovered;
	Tooltip mToolTip;
	std::function<void (IconButton*)> mClickCallback;

	void ReloadVertices();
	void OnMouseMove(ui32 x, ui32 y, bool leftDown, bool rightDown);
public:
	IconButton(const std::string& iconFile);

	void SetSize(ui32 size)
	{
		mSize = size;
		ReloadVertices();
	}

	void SetClickCallback(std::function<void (IconButton*)> click)
	{
		mClickCallback = click;
	}

	void SetPosition(ui32 x, ui32 y)
	{
		mPosX = x;
		mPosY = y;
		ReloadVertices();
	}

	void ModPosition(i32 x, i32 y)
	{
		mPosX += x;
		mPosY += y;
		ReloadVertices();
	}

	bool IsHovered() { return mIsHovered; }
	void SetTooltip(const std::string& title, const std::string& message)
	{
		mToolTip.SetMessage(message);
		mToolTip.SetTitle(title);
	}

	void MouseActivity(bool left, Vertex2F pos, bool up);
	void OnMouseClick() { mClickCallback(this); }

	void Draw();
};